package org.jiamandan.com.controller;

import cn.hutool.extra.spring.SpringUtil;
import lombok.AllArgsConstructor;
import org.jiamandan.com.service.IRechargePileService;
import org.jiamandan.com.utils.RedisUtil;
import org.springframework.web.bind.annotation.*;

@RestController
@AllArgsConstructor
@RequestMapping("/charge-test")
public class ChargeTestController {

    private IRechargePileService iRechargePileService;

    /**
     * jmd-2口下发测试通电
     * @param pileNo  设备编号
     * @param gunNo   充电枪号
     * @param isOpen  0停止充电  1开启充电
     * @return
     */
    @GetMapping("/testJsy2charge")
    //TODO 严重声明，本测试是两路测试，测试10路需要更改code
    public String testJsy2charge(@RequestParam String pileNo, @RequestParam String gunNo, @RequestParam Integer isOpen){
        iRechargePileService.testJsy2charge(pileNo,gunNo,isOpen);
        return "下发成功";
    }

    /**
     * jmd-下发修改时间  使用1015
     * @param pileNo  设备编号
     * @return
     */
    @GetMapping("/testJsy2Bomb")
    public String testJsy2Bomb(@RequestParam String pileNo){
        String gunNo = "0";
        iRechargePileService.testJsy2Bomb(pileNo,gunNo);
        return "下发成功";
    }

    /**
     * jmd-下发修改时间  使用1015
     * @param pileNo  设备编号
     * @param gunNo   充电枪号
     * @return
     */
    @GetMapping("/testJsy2Time")
    public String testJsy2Time(@RequestParam String pileNo,@RequestParam String gunNo){
        iRechargePileService.testJsy2Time(pileNo,gunNo);
        return "下发成功";
    }

    /**
     * TODO 严重声明该设备已停产
     * jmd-10下发通电测试，
     * @param pileNo  设备编号
     * @param gunNo   充电枪号
     * @param isOpen  0停止充电  1开启充电
     * @return
     */
    @GetMapping("/testJsy10charge")
    public String testJsy10charge(@RequestParam String pileNo,@RequestParam String gunNo,@RequestParam Integer isOpen){
        try {
            iRechargePileService.testJsy10charge(pileNo,gunNo,isOpen);
        }catch (Exception e){
            return e.getMessage();
        }
        return "下发成功";
    }

    /**
     * TODO 严重声明该设备已停产
     * 检测是否在线
     * @param pileNo  设备编号
     * @return
     */
    @GetMapping("/testJsy10online")
    public String testJsy10online(@RequestParam String pileNo){
        return iRechargePileService.testJsy10online(pileNo);
    }

}
